package excel

import (
	"github.com/xuri/excelize/v2"
)

func readOrderFile(filePath string) (dbRecords []*Order, err error) {
	f, err := excelize.OpenFile(filePath)
	if err != nil {
		println(err.Error())
		return
	}
	rows, err := f.GetRows("Orders")
	if err != nil {
		return
	}
	for i := 1; i < len(rows); i++ {
		var cur = new(Order)
		cur.OrderId = rows[i][0]
		cur.Uid = rows[i][3]
		cur.OrderDate = rows[i][6]
		cur.PrdType = rows[i][4]
		dbRecords = append(dbRecords, cur)
	}
	return
}

var SheetName = "Sheet1"

type TimeConfig struct {
	Id         string `json:"id"`
	CampaignId string `json:"campaign_id"`
	Locale     string `json:"Locale"`
}

type Order struct {
	Uid       string `json:"uid"`
	OrderId   string `json:"orderid"`
	OrderDate string `json:"orderdate"`
	PrdType   string `json:"prdtype"`
}

type OrderJson struct {
	Uid       string `json:"uid"`
	OrderId   int64  `json:"orderId"`
	OrderDate int64  `json:"createTime"`
}
